//
//  Player.cpp
//  party-family
//
//  Created by Justin Kurtz on 7/7/11.
//

#include "Player.h"

Player::Player() 
{
   health = new Health();
   inventory = new Inventory();
   
   maxEquippableItems = 2;
   maxNumItems = 2;
}

Player::~Player()
{
   // free images
   
   delete health;
   delete inventory;
}

void Player::Jump()
{
   
}

int Player::GetHealth()
{
   return health->GetHealth();
}

float Player::GetHealthPercentage()
{
   return health->GetHealthPercentage();
}

void Player::SetMaxHealth(int amount)
{
   health->SetMaxHealth(amount);
}

void Player::Kill()
{
   health->Kill();
}

void Player::RestoreToMax()
{
   health->RestoreToMax();
}

bool Player::IsAlive()
{
   return health->IsAlive();
}

void Player::Damage(int amount)
{
   health->Damage(amount);
}

void Player::Heal(int amount)
{
   health->AddHealth(amount);
}

int Player::GetNumItems()
{
   return inventory->GetNumItems();
}

void Player::EquipItem(Item *item)
{
   equippedItems.push_back(*item);
}

void Player::UnEquipAll()
{
   equippedItems.clear();
}

// this needs tuning.
void Player::UnEquipItem(Item *item)
{
   std::vector<Item>::iterator it;
   
   for(it = equippedItems.begin(); it < equippedItems.end(); it++)
   {
      if(*it == *item) {
         equippedItems.erase(it);
      }
   }
}

std::vector<Item> Player::GetEquippedItems()
{
   return equippedItems;
}

int Player::GetMaxEquippableItems()
{
   return maxEquippableItems;
}

int Player::GetMaxNumItems()
{
   return maxNumItems;
}

void Player::SetMaxNumItems(int newNum)
{
   maxNumItems = newNum;
}

void Player::SetMaxEquippableItems(int newNum)
{
   maxEquippableItems = newNum;
}

void Player::PickupItem(Item *item)
{
   if(!inventory->IsFull())
   {
      inventory->PickupItem(item);
   }
}

void Player::DropItem(Item *item)
{
   if(!inventory->IsEmpty())
   {
      inventory->DropItem(item);
   }
}
